<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>{:t('优惠券')}设置</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  {include file="public/css"/}
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-card layui-col-md12">
				<div class="layui-card-header">
					{if !$info['id']}<i class="fa fa-plus"></i> 添加{:t('优惠券')}{else}<i class="fa fa-pencil"></i> 编辑{:t('优惠券')}{/if}
					<i class="layui-icon layui-icon-close" style="font-size:18px;font-weight:bold;cursor:pointer" onclick="closeself()"></i>
				</div>
				<div class="layui-card-body" pad15>
					<div class="layui-form form-label-w6" lay-filter="">
						<input type="hidden" name="info[id]" value="{$info['id']}">
						<input type="hidden" name="info[type]" value="5">
					    {if $show_coupon_type}
						<div class="layui-form-item">
							<label class="layui-form-label">{:t('优惠券')}类型：</label>
							<div class="layui-input-inline" style="width:700px">
								<input type="radio" name="info[type]" value="5" title="餐饮代金券" {if !$info['id'] || $info['type']==1}checked{/if} lay-filter="coupon_type">
								{if getcustom('restaurant_cashdesk_free_coupon')}
								<input type="radio" name="info[type]" value="51" title="免费券" {if !$info['id'] || $info['type']==51}checked{/if} lay-filter="coupon_type">
								{/if}
								{if getcustom('restaurant_cashdesk_discount_coupon')}	
								<input type="radio" name="info[type]" value="10" title="折扣券" {if !$info['id'] || $info['type']==10}checked{/if} lay-filter="coupon_type">
								{/if}
							</div>
							<div class="layui-word-aux layui-clear">代金券：可以直接抵扣金额使用；{if getcustom('restaurant_cashdesk_free_coupon')}免费券：直接抵扣订单金额，标记支付类型为免费券；{/if}</div>
						</div>
						{/if}
						<div class="layui-form-item">
							<label class="layui-form-label">{:t('优惠券')}名称：</label>
							<div class="layui-input-inline">
								<input type="text" name="info[name]" value="{$info.name}" lay-verify="required" lay-verType="tips" autocomplete="off" class="layui-input">
							</div>
						</div>
					   
						<div class="layui-form-item coupon_type5" {if $info['type'] ==51}style="display:none"{/if}>
							<label class="layui-form-label">优惠金额：</label>
							<div class="layui-input-inline">
								<input type="text" name="info[money]" value="{$info.money}" autocomplete="off" class="layui-input">
							</div>
							<div class="layui-form-mid">元</div>
							<div class="layui-word-aux layui-clear">注：用于菜品订单抵扣时，{:t('优惠券')}只能抵消菜品金额，不能抵消运费</div>
						</div>
						<div class="layui-form-item coupon_type5" {if $info['type'] ==51}style="display:none"{/if}>
							<label class="layui-form-label">最低消费金额：</label>
							<div class="layui-input-inline">
								<input type="text" name="info[minprice]" value="{$info.minprice|default=0}" lay-verify="required" lay-verType="tips" autocomplete="off" class="layui-input">
							</div>
							<div class="layui-form-mid">元</div>
							<div class="layui-word-aux layui-clear"> 注：购物金额（不含运费）达到最低消费金额才可使用{:t('优惠券')}，无门槛{:t('优惠券')}请填0</div>
						</div>
						<div class="layui-form-item coupon_type10" {if $info['type']!=10}style="display:none"{/if}>
							<label class="layui-form-label">折扣比例：</label>
							<div class="layui-input-inline">
							  <input type="text" name="info[discount]" value="{$info.discount}" autocomplete="off" class="layui-input">
							</div>
							<div class="layui-form-mid">%</div>
							<div class="layui-word-aux" style="clear:both;margin-left:125px">例如9折{:t('优惠券')}则填写90</div>
						</div>			
		  
						<div class="layui-form-item">
							<label class="layui-form-label">适用范围：</label>
							<div class="layui-input-inline" style="width:500px">
								<input type="radio" name="info[fwtype]" value="0" {if $info['fwtype']==0}checked{/if} title="全场通用" lay-filter="fwtype"/>
								<input type="radio" name="info[fwtype]" value="1" {if $info['fwtype']==1}checked{/if} title="指定类目" lay-filter="fwtype"/>
								<input type="radio" name="info[fwtype]" value="2" {if $info['fwtype']==2}checked{/if} title="指定菜品" lay-filter="fwtype"/>
							</div>
							<div class="fwtype1 fwtypeExtend" style="clear:both;{if $info['fwtype']!=1}display:none{/if}">
								<label class="layui-form-label"></label>
								<div class="layui-input-inline" style="width:auto">
									<table id="setcategorydiv"  class="layui-table" style="width:500px">
										<thead>
										<tr>
											<th>分类ID</th>
											<th>分类名称</th>
											<th>操作</th>
										</tr>
										</thead>
										{if $categorydata}
										{foreach $categorydata as $k=>$ff}
										<tr class="categorylisttr"><td>{$ff.id}</td><td>{$ff.name}</td><td><button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="delCategory(this,{$ff.id})">删除</button></td></tr>
										{/foreach}
										{/if}
										<tr id="categoryaddtr">
											<td colspan="3"><button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="showChooseCategory()">添加</button></td>
										</tr>
									</table>
									<input type="hidden" name="info[categoryids]" value="{$info.categoryids}"/>
								</div>
							</div>
							<script>
							var chooseCategoryLayer;
							function showChooseCategory(){
								chooseCategoryLayer = layer.open({type:2,title:'选择菜品分类',content:"{:url('RestaurantProductCategory/choosecategory')}",area:['1000px','600px'],shadeClose:true});
							}
							function chooseCategory(fid,fname){
								layer.close(chooseCategoryLayer);
								var categoryids = [];
								var isadd = 0;
								$('.categorylisttr').each(function(){
									var thisfid = $(this).find('td:eq(0)').html();
									if(thisfid == fid){
										isadd = 1
										dialog('该分类已添加过了');
									}
									categoryids.push(thisfid)
								})
								if(isadd == 0){
									categoryids.push(fid)
									$("input[name='info[categoryids]']").val(categoryids.join(','));
									$('#categoryaddtr').before('<tr class="categorylisttr"><td>'+fid+'</td><td>'+fname+'</td><td><button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="delCategory(this,'+fid+')">删除</button></td></tr>');
								}
								console.log(categoryids)
							}
							function delCategory(obj,fid){
								$(obj).parent().parent().remove();
								var categoryids = [];
								$('.categorylisttr').each(function(){
									categoryids.push($(this).find('td:eq(0)').html())
								})
								$("input[name='info[categoryids]']").val(categoryids.join(','));
							}
							</script>
							<div class="fwtype2 fwtypeExtend" style="clear:both;{if $info['fwtype']!=2}display:none{/if}">
								<label class="layui-form-label"></label>
								<div class="layui-input-inline" style="width:auto">
									<table id="setproductdiv"  class="layui-table" style="width:500px">
										<thead>
										<tr>
											<th>菜品ID</th>
											<th>菜品名称</th>
											<th>操作</th>
										</tr>
										</thead>
										{if $productdata}
										{foreach $productdata as $k=>$ff}
										<tr class="productlisttr"><td>{$ff.id}</td><td>{$ff.name}</td><td><button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="delProduct(this,{$ff.id})">删除</button></td></tr>
										{/foreach}
										{/if}
										<tr id="productaddtr">
											<td colspan="3"><button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="showChooseProduct()">添加</button></td>
										</tr>
									</table>
									<input type="hidden" name="info[productids]" value="{$info.productids}"/>
								</div>
							</div>
							<script>
							var chooseProductLayer;
							function showChooseProduct(){
								chooseProductLayer = layer.open({type:2,title:'选择菜品',content:"{:url('RestaurantProduct/chooseproduct')}/hidebid/1",area:['1000px','600px'],shadeClose:true});
							}
							function choosepro(res){
								var product = res.product
								layer.close(chooseProductLayer);
								var productids = [];
								var isadd = 0;
								$('.productlisttr').each(function(){
									var thisfid = $(this).find('td:eq(0)').html();
									if(thisfid == product.id){
										isadd = 1
										dialog('该菜品已添加过了');
									}
									productids.push(thisfid)
								})
								if(isadd == 0){
									productids.push(product.id)
									$("input[name='info[productids]']").val(productids.join(','));
									$('#productaddtr').before('<tr class="productlisttr"><td>'+product.id+'</td><td>'+product.name+'</td><td><button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="delProduct(this,'+product.id+')">删除</button></td></tr>');
								}
								console.log(productids)
							}
							function delProduct(obj,fid){
								$(obj).parent().parent().remove();
								var productids = [];
								$('.productlisttr').each(function(){
									productids.push($(this).find('td:eq(0)').html())
								})
								$("input[name='info[productids]']").val(productids.join(','));
							}
							</script>
							
						</div>
					    {if getcustom('restaurant_coupon_apply_business')}
						{if $bid==0}
						<div class="layui-form-item">
							<label class="layui-form-label">适用商户：</label>
							<div class="layui-input-inline" style="width:200px">
								<input type="radio" name="info[apply_business_type]" value="0" {if $info['apply_business_type']==0}checked{/if} title="全部" lay-filter="apply_business_type"/>
								<input type="radio" name="info[apply_business_type]" value="1" {if !$info['id'] ||  $info['apply_business_type']==1}checked{/if} title="选择商户" lay-filter="apply_business_type"/>
							</div>
							<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">开启后商户承担，平台不补</div>
							<div class="apply_business1 fwtypeExtend" style="clear:both;{if 
						    $info['id'] && $info['apply_business_type']!=1}display:none{/if}">
								<label class="layui-form-label"></label>
								<div class="layui-input-inline" style="width:auto">
									<table id="applybusinessdiv"  class="layui-table" style="width:500px">
										<thead>
										<tr>
											<th>商户ID</th>
											<th>商户名称</th>
											<th>操作</th>
										</tr>
										</thead>
										{if $businessdata}
										{foreach $businessdata as $k=>$ff}
										<tr class="businesslisttr"><td>{$ff.id}</td><td>{$ff.name}</td><td><button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="delBusiness(this,{$ff.id})">删除</button></td></tr>
										{/foreach}
										{/if}
										<tr id="businessaddtr">
											<td colspan="3"><button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="showChooseBusiness()">添加</button></td>
										</tr>
									</table>
									<input type="hidden" name="info[apply_businessids]" value="{$info.apply_businessids}"/>
								</div>
							</div>
							<script>
								var chooseBusinessLayer;
								function showChooseBusiness(){
									chooseBusinessLayer = layer.open({type:2,title:'选择商户',content:"{:url('Business/choosebusiness')}",area:['1000px','600px'],shadeClose:true});
								}
								function choosebusiness(data){
									var fid = data.id;
									var fname = data.name;
									layer.close(chooseCategoryLayer);
									var businessids = [];
									var isadd = 0;
									$('.businesslisttr').each(function(){
										var thisfid = $(this).find('td:eq(0)').html();
										if(thisfid == fid){
											isadd = 1
											dialog('该商户已添加过了');
										}
										businessids.push(thisfid)
									})
									if(isadd == 0){
										businessids.push(fid)
										$("input[name='info[apply_businessids]']").val(businessids.join(','));
										$('#businessaddtr').before('<tr class="businesslisttr"><td>'+fid+'</td><td>'+fname+'</td><td><button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="delBusiness(this,'+fid+')">删除</button></td></tr>');
									}
									console.log(businessids)
								}
								function delBusiness(obj,fid){
									$(obj).parent().parent().remove();
									var businessids = [];
									$('.businesslisttr').each(function(){
										businessids.push($(this).find('td:eq(0)').html())
									})
									$("input[name='info[apply_businessids]']").val(businessids.join(','));
								}
							</script>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label">适用平台：</label>
							<div class="layui-input-inline">
								<input type="radio" name="info[apply_platform]" value="0" {if  $info['apply_platform']==0}checked{/if} title="关闭" />
								<input type="radio" name="info[apply_platform]" value="1" {if !$info['id'] || $info['apply_platform']==1}checked{/if} title="开启" />
							</div>
							<div class="layui-form-mid layui-word-aux" style="margin-left:10px;"></div>
						</div>
						{/if}
						{/if}

						<div class="layui-form-item">
							<label class="layui-form-label">使用说明：</label>
							<div class="layui-input-inline" style="width:300px">
								<textarea name="info[usetips]" class="layui-textarea">{$info.usetips}</textarea>
							</div>
							<div class="layui-form-mid layui-word-aux"></div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label">有效期：</label>
							<div class="layui-input-inline" style="width:500px">
								<input type="radio" name="info[yxqtype]" value="1" title="固定时间范围" {if !$info['id'] || $info['yxqtype']==1}checked{/if} lay-filter="yxqtype"/>
								<input type="radio" name="info[yxqtype]" value="2" title="领取后时长" {if $info['yxqtype']==2}checked{/if} lay-filter="yxqtype"/>
								<input type="radio" name="info[yxqtype]" value="3" title="领取后时长（次日起）" {if $info['yxqtype']==3}checked{/if} lay-filter="yxqtype"/>
							</div>
						</div>
						<div class="layui-form-item yxqtimeitem" id="yxqtimeitem_1" {if $info['id'] && $info['yxqtype']!=1}style="display:none"{/if}>
							<label class="layui-form-label"></label>
							<div class="layui-form-mid">有效期时间</div>
							<div class="layui-input-inline" style="width:300px">
								<input type="text" name="info[yxqtime]" value="{$info.yxqtime}" id="yxqtime" autocomplete="off" class="layui-input"/>
							</div>
						</div>
						<div class="layui-form-item yxqtimeitem" id="yxqtimeitem_2" {if $info['yxqtype']!=2}style="display:none"{/if}>
							<label class="layui-form-label"></label>
							<div class="layui-form-mid">领取后</div>
							<div class="layui-input-inline" style="width:70px">
								<input type="text" name="yxqdate2" value="{$info.yxqdate}" class="layui-input"/>
							</div>
							<div class="layui-form-mid">天内有效</div>
						</div>
						  <div class="layui-form-item yxqtimeitem" id="yxqtimeitem_3" {if $info['yxqtype']!=3}style="display:none"{/if}>
							  <label class="layui-form-label"></label>
							  <div class="layui-form-mid">领取后</div>
							  <div class="layui-input-inline" style="width:70px">
								  <input type="text" name="yxqdate3" value="{$info.yxqdate}" class="layui-input"/>
							  </div>
							  <div class="layui-form-mid">天内有效（次日0点开始计算有效期）</div>
						  </div>


		<div class="layui-form-item">
							<label class="layui-form-label"><span class="redstar">*</span>参与条件：</label>
							<div class="layui-input-inline" style="width:600px">
								<input type="checkbox" name="info[gettj][]" value="-1" title="所有人" {if in_array('-1',$info['gettj'])}checked{/if}/>
								<!-- <input type="checkbox" name="info[gettj][]" value="0" title="关注用户" {if in_array('0',$info['gettj'])}checked{/if}/> -->
								{foreach $memberlevel as $v}
								<input type="checkbox" name="info[gettj][]" value="{$v.id}" title="{$v.name}" {if in_array($v['id'],$info['gettj'])}checked{/if}/>
								{/foreach}
							</div>
						</div>
						
						<div class="layui-form-item">
							<label class="layui-form-label">所需金额：</label>
							<div class="layui-input-inline">
								<input type="text" name="info[price]" value="{$info.price|default=0}" lay-verify="required" lay-verType="tips" autocomplete="off" class="layui-input">
							</div>
							<div class="layui-form-mid layui-word-aux">需要消耗多少钱购买</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">所需{:t('积分')}：</label>
							<div class="layui-input-inline">
								<input type="text" name="info[score]" value="{$info.score|default=0}" lay-verify="required" lay-verType="tips" autocomplete="off" class="layui-input">
							</div>
							<div class="layui-form-mid layui-word-aux">需要消耗多少{:t('积分')}兑换</div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label">库存：</label>
							<div class="layui-input-inline">
								<input type="text" name="info[stock]" value="{$info.stock|default=100}" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">每人可领取数：</label>
							<div class="layui-input-inline">
								<input type="text" name="info[perlimit]" value="{$info['perlimit']}" class="layui-input">
							</div>
							<div class="layui-form-mid layui-word-aux">每人最多可领取多少张</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">开始时间：</label>
							<div class="layui-input-inline">
								<input type="text" name="info[starttime]" autocomplete="off" value="{$info.starttime}" lay-verify="required" lay-verType="tips" class="layui-input" id="starttime">
							</div>
							<div class="layui-form-mid layui-word-aux">活动开始时间</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">结束时间：</label>
							<div class="layui-input-inline">
								<input type="text" name="info[endtime]" autocomplete="off" value="{$info.endtime}" lay-verify="required" lay-verType="tips" class="layui-input" id="endtime">
							</div>
							<div class="layui-form-mid layui-word-aux">活动结束时间</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">序号：</label>
							<div class="layui-input-inline">
								<input type="text" name="info[sort]" value="{$info.sort}" class="layui-input">
							</div>
							<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">用于排序,越大越靠前</div>
						</div>
						
						<div class="layui-form-item">
							<label class="layui-form-label">可直接领取：</label>
							<div class="layui-input-inline">
								<input type="radio" name="info[tolist]" value="1" {if !$info['id'] || $info['tolist']==1}checked{/if} title="是"/>
								<input type="radio" name="info[tolist]" value="0" {if $info['id'] && $info['tolist']==0}checked{/if} title="否"/>
							</div>
							<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">是否可以在领券中心直接领取</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">使用范围：</label>
							<div class="layui-input-inline" style="width: 430px">
								<input type="radio" name="info[isgive]" value="0" {if !$info['id'] || $info['isgive']==0}checked{/if} title="仅自用" lay-filter="isgive"/>
								<input type="radio" name="info[isgive]" value="1" {if $info['id'] && $info['isgive']==1}checked{/if} title="自用+转赠" lay-filter="isgive"/>
								<input type="radio" name="info[isgive]" value="2" {if  $info['id'] && $info['isgive']==2}checked{/if} title="仅转赠" lay-filter="isgive"/>
							</div>
							<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">{:t('优惠券')}使用范围，自用或转赠</div>
						</div>
						<div style="{if !$info['id'] || $info['isgive']==0}display:none{/if}" id="isgive">
							{if getcustom('usecoupon_give_coupon')}
							<div class="layui-form-item">
								<label class="layui-form-label">好友使用后<br>赠送{:t('优惠券')}：</label>
								<div class="layui-input-inline" style="width:auto; overflow: hidden;">
									<table class="layui-table choose-coupon" style="width:500px" id="choose-coupon">
										<thead>
										<tr>
											<th>ID</th>
											<th>名称</th>
											<th>库存</th>
											<th>操作</th>
										</tr>
										</thead>
										{if $couponList}
										{foreach $couponList as $k=>$ff}
										<tr class="choose-tr-list"><td>{$ff.id}</td><td>{$ff.name}</td><td>{$ff.stock}</td><td><button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="delChooseTr(this,{$ff.id})">删除</button></td></tr>
										{/foreach}
										{/if}
										<tr class="choose-tr-add">
											<td colspan="4"><button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="showChooseCoupon()">添加</button></td>
										</tr>
									</table>
									<div class="layui-form-mid layui-word-aux">请确认{:t('优惠券')}的有效期、库存有效</div>
									<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">转赠的{:t('优惠券')}被使用后，转赠人获得{:t('优惠券')}</div>
									<input type="hidden" name="info[usecoupon_give_coupon]" value="{$info.usecoupon_give_coupon}"/>
								</div>

								<script>
									var chooseCouponLayer;
									function showChooseCoupon(){
										chooseCouponLayer = layer.open({type:2,title:'选择{:t(\'优惠券\')}',content:"{:url('Coupon/choosecoupon')}&type=all",area:['1000px','600px'],shadeClose:true});
									}
									function choosecoupon(res){
										var detail = res;
										var chooseClassName = '.choose-coupon';
										layer.close(chooseCouponLayer);
										var objIds = [];
										var isadd = 0;
										$(chooseClassName).find('.choose-tr-list').each(function(){
											var thisfid = $(this).find('td:eq(0)').html();
											if(thisfid == detail.id){
												isadd = 1
												dialog('该项已添加过了');
											}
											objIds.push(thisfid)
										})
										if(isadd == 0){
											objIds.push(detail.id)
											$("input[name='info[usecoupon_give_coupon]']").val(objIds.join(','));
											var tr = '<tr class="choose-tr-list"><td>'+detail.id+'</td><td>'+detail.name+'</td><td>'+detail.stock+'</td><td><button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="delChooseTr(this,'+detail.id+')">删除</button></td></tr>';
											$(chooseClassName).find('.choose-tr-add').before(tr);
										}
										// $(chooseClassName).find('.choose-tr-add').hide();
									}
									function delChooseTr(obj,fid){
										$(obj).closest('.choose-tr-list').remove();
										var objIds = [];
										$('#choose-coupon').find('.choose-tr-list').each(function(){
											objIds.push($(this).find('td:eq(0)').html())
										})
										console.log(objIds)
										$("input[name='info[coupon_ids]']").val(objIds.join(','));
										// $(obj).closest('table').find('.choose-tr-add').show();
									}
								</script>
							</div>
							{/if}
							{if $bid == 0}
							{if getcustom('usecoupon_give_money')}
							<div class="layui-form-item">
								<label class="layui-form-label">好友使用后<br>赠送{:t('余额')}：</label>
								<div class="layui-input-inline">
									<input type="number" class="layui-input" name="info[usecoupon_give_money]" value="{$info.usecoupon_give_money|default=0}">
								</div>
								<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">转赠的{:t('优惠券')}被使用后，转赠人获得{:t('余额')}</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">好友使用后<br>赠送{:t('佣金')}：</label>
								<div class="layui-input-inline">
									<input type="number" class="layui-input" name="info[usecoupon_give_commission]" value="{$info.usecoupon_give_commission|default=0}">
								</div>
								<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">转赠的{:t('优惠券')}被使用后，转赠人获得{:t('佣金')}</div>
							</div>
							{/if}
							{if getcustom('usecoupon_give_score')}
							<div class="layui-form-item">
								<label class="layui-form-label">好友使用后<br>赠送{:t('积分')}：</label>
								<div class="layui-input-inline">
									<input type="number" class="layui-input" name="info[usecoupon_give_score]" value="{$info.usecoupon_give_score|default=0}">
								</div>
								<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">转赠的{:t('优惠券')}被使用后，转赠人获得{:t('积分')}</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">使用后<br>赠送时间：</label>
								<div class="layui-input-inline" style="width:260px">
									<input type="radio" name="info[usecoupon_give_type]" value="1" {if !$info['id'] || $info['usecoupon_give_type']==1}checked{/if} title="支付后"/>
									<input type="radio" name="info[usecoupon_give_type]" value="2" {if $info['id'] && $info['usecoupon_give_type']==2}checked{/if} title="确认收货后"/>
								</div>
								<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">订单发生退款时，不返还已使用的{:t('优惠券')}，也不扣除赠送的{:t('积分')}</div>
							</div>
							{/if}
							{/if}
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">支付后赠送：</label>
							<div class="layui-input-inline">
								<input type="radio" name="info[paygive]" value="0" {if !$info['id'] || $info['paygive']==0}checked{/if} title="关闭" lay-filter="paygive"/>
								<input type="radio" name="info[paygive]" value="1" {if $info['id'] && $info['paygive']==1}checked{/if} title="开启" lay-filter="paygive"/>
							</div>
							<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">支付成功后自动发放{:t('优惠券')}</div>
						</div>
						<div style="{if !$info['id'] || $info['paygive']==0}display:none{/if}" id="paygiveset">
							<div class="layui-form-item">
								<label class="layui-form-label">支付赠送场景：</label>
								<div class="layui-input-inline" style="width:600px">
									{php} $paygive_scenes = explode(',',$info['paygive_scene']);{/php}
									<input type="checkbox" name="info[paygive_scene][]" value="restaurant" {if in_array('restaurant',$paygive_scenes)}checked{/if} title="下单"/>
									<input type="checkbox" name="info[paygive_scene][]" value="recharge" {if in_array('recharge',$paygive_scenes)}checked{/if} title="充值"/>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">支付金额范围：</label>
								<div class="layui-input-inline" style="width:100px">
									<input type="text" name="info[paygive_minprice]" value="{$info.paygive_minprice|default=0}" class="layui-input">
								</div>
								<div class="layui-form-mid">-</div>
								<div class="layui-input-inline" style="width:100px">
									<input type="text" name="info[paygive_maxprice]" value="{$info.paygive_maxprice|default=9999}" class="layui-input">
								</div>
								<div class="layui-form-mid">元</div>
							</div>
						</div>
						
						<div class="layui-form-item">
							<label class="layui-form-label"></label>
							<div class="layui-input-block">
								<button class="layui-btn" lay-submit lay-filter="formsubmit">提 交</button>
							</div>
						</div>
					</div>
					
				</div>
			</div>
    </div>
  </div>
	{include file="public/js"/}
	<script>

	layui.form.on('radio(coupon_type)',function(data){
		if(data.value==5){
			$('.coupon_type5').show();
			$('.coupon_type51').hide();
			$('.coupon_type10').hide();
		}else if(data.value==10){
			$('.coupon_type10').show();
			$('.coupon_type5').hide();
			$('.coupon_type51').hide();
		}else if(data.value==51){
			$('.coupon_type51').show();
			$('.coupon_type5').hide();
			$('.coupon_type10').hide();
		}
	});
	
	layui.form.on('radio(yxqtype)',function(data){
		$('.yxqtimeitem').hide();
		$('#yxqtimeitem_'+data.value).show();
	})
	layui.form.on('radio(isgive)',function(data){
		if(data.value==1 || data.value==2){
			$('#isgive').show();
		}else{
			$('#isgive').hide();
		}
	})
	layui.form.on('radio(paygive)',function(data){
		if(data.value==1){
			$('#paygiveset').show();
		}else{
			$('#paygiveset').hide();
		}
	})
	layui.form.on('radio(fwtype)',function(data){
		$('.fwtypeExtend').hide();
		$('.fwtype' + data.value).show();
	})
	layui.form.on('radio(buyprogive)',function(data){
		if(data.value==1){
			$('.buyprogive').show();
		}else{
			$('.buyprogive').hide();
		}
	})
	layui.form.on('radio(buy_restaurant_product_give)',function(data){
		if(data.value==1){
			$('.buy_restaurant_product_give').show();
		}else{
			$('.buy_restaurant_product_give').hide();
		}
	})
	layui.laydate.render({ 
		elem: '#starttime'
		,type: 'datetime'
		,range: false,
		trigger: 'click'
	});
	layui.laydate.render({ 
		elem: '#endtime'
		,type: 'datetime'
		,range: false,
		trigger: 'click'
	});
	layui.laydate.render({ 
		elem: '#yxqtime'
		,type: 'datetime'
		,range: '~',
		trigger: 'click'
	});

	layui.form.on('submit(formsubmit)', function(obj){
		var field = obj.field
		var index = layer.load();
		$.post("{:url('save')}",field,function(data){
			layer.close(index);
			dialog(data.msg,data.status);
			if(data.status == 1){
				setTimeout(function(){
					parent.layer.closeAll();
					parent.tableIns.reload()
				},1000)
			}
		})
	})
	 {if getcustom('restaurant_coupon_apply_business')}
	layui.form.on('radio(apply_business_type)',function(data){
		if(data.value==1){
			$('.apply_business1').show();
		}else{
			$('.apply_business1').hide();
		}
	})
	{/if}
  </script>
	{include file="public/copyright"/}
</body>
</html>